package com.mgfireworks.mgplatform.mgadmin.sys;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.mgfireworks.mgplatform.mgadmin.sys.model.Organization;

import cn.hn.java.summer.annotation.ParamValid;

/**
 * 
 * @author nap
 * 20161015-10:19:48
 * 机构控制器
 */
@Controller
@RequestMapping("/sys/org")
public class OrganizationController {

	@Autowired
	OrganizationService organizationService;
	
	/**
	 * 机构列表
	 * @return
	 */
	@RequestMapping("/list")
	public List<Organization> list(Organization p){
		return organizationService.getOrganizations(p);
	}
	
	/**
	 * 选择机构列表
	 * @return
	 */
	@RequestMapping("/select")
	public List<Organization> select(Organization p){
		return organizationService.getOrganizations(p);
	}

	/**
	 * 添加机构
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public Organization add(){
		return organizationService.newOrganization();
	}
	
	/**
	 * 提交添加机构
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	public void postAdd(@ParamValid Organization p){
		organizationService.addOrganization(p);
	}

	/**
	 * 编辑机构
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public Organization edit(Organization p){
		return organizationService.getOrganization(p);
	}
	
	/**
	 * 提交编辑机构
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	public void postEdit(@ParamValid Organization p){
		organizationService.editOrganization(p);
	}
	
	/**
	 * 获取机构
	 */
	@RequestMapping(value="/get",method=RequestMethod.GET)
	public Organization get(Organization p){
		return organizationService.getOrganization(p);
	}
	
	/**
	 * 删除机构
	 */
	@RequestMapping("/del")
	public void del(Organization p){
		organizationService.delOrganization(p);
	}
}